load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "ttlworker",
    srcs = [
        "config.go",
        "del.go",
        "job.go",
        "job_manager.go",
        "scan.go",
        "session.go",
        "task_manager.go",
        "timer.go",
        "timer_sync.go",
        "worker.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/ttl/ttlworker",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/infoschema",
        "//pkg/kv",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser/model",
        "//pkg/parser/terror",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/store/driver/error",
        "//pkg/timer/api",
        "//pkg/timer/runtime",
        "//pkg/timer/tablestore",
        "//pkg/ttl/cache",
        "//pkg/ttl/client",
        "//pkg/ttl/metrics",
        "//pkg/ttl/session",
        "//pkg/ttl/sqlbuilder",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/chunk",
        "//pkg/util/intest",
        "//pkg/util/logutil",
        "//pkg/util/sqlexec",
        "//pkg/util/timeutil",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@io_etcd_go_etcd_client_v3//:client",
        "@org_golang_x_exp//maps",
        "@org_golang_x_time//rate",
        "@org_uber_go_multierr//:multierr",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "ttlworker_test",
    timeout = "moderate",
    srcs = [
        "del_test.go",
        "job_manager_integration_test.go",
        "job_manager_test.go",
        "scan_test.go",
        "session_test.go",
        "task_manager_integration_test.go",
        "task_manager_test.go",
        "timer_sync_test.go",
        "timer_test.go",
    ],
    embed = [":ttlworker"],
    flaky = True,
    race = "on",
    shard_count = 50,
    deps = [
        "//pkg/domain",
        "//pkg/infoschema",
        "//pkg/infoschema/context",
        "//pkg/kv",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser/ast",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/session",
        "//pkg/sessionctx",
        "//pkg/sessionctx/variable",
        "//pkg/statistics",
        "//pkg/store/mockstore",
        "//pkg/testkit",
        "//pkg/timer/api",
        "//pkg/timer/tablestore",
        "//pkg/ttl/cache",
        "//pkg/ttl/client",
        "//pkg/ttl/metrics",
        "//pkg/ttl/session",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/chunk",
        "//pkg/util/logutil",
        "//pkg/util/mock",
        "@com_github_google_uuid//:uuid",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_prometheus_client_model//go",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//mock",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//testutils",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@org_golang_x_time//rate",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)
